package com.example.othree.service.impl;

import com.example.othree.service.AbnormalAlarmsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;

@Service
public class AbnormalAlarmsServiceImpl implements AbnormalAlarmsService {

    @Autowired
    private JavaMailSender mailSender;

    @Value("${spring.mail.username}")
    String fromEmail;

    @Override
    public void abnormalAlarmsEmail(String toEmail, String theme, String content) {

        SimpleMailMessage message = new SimpleMailMessage();
        message.setFrom(fromEmail);
        message.setTo(toEmail);
        message.setSubject(theme);
        message.setText(content);

        mailSender.send(message);
    }



}
